package org.mspring.mlog.service;

import org.mspring.mlog.dao.WeiboDao;
import org.mspring.mlog.entity.Weibo;
import org.mspring.nbee.db.dao.sql.builder.part.condition.SqlCondition;
import org.mspring.nbee.db.dao.sql.pager.PageResult;
import org.mspring.nbee.db.dao.sql.pager.Pager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author Gao Youbo
 * @since 2015-02-21 18:25:36
 */
@Service
public class WeiboService {

    private static final Logger LOG = LoggerFactory.getLogger(WeiboService.class);

    private WeiboDao weiboDao;

    public Weibo findById(long id) {
        return weiboDao.findById(id);
    }

    public PageResult<Weibo> list(List
                                          <SqlCondition> conditions, Pager pager) {
        return weiboDao.listPage(conditions, pager);
    }

    @Transactional
    public boolean insert(Weibo weibo) {
        return weiboDao.insert(weibo);
    }

    @Transactional
    public boolean update(Weibo weibo) {
        return weiboDao.update(weibo);
    }

    @Transactional
    public boolean deleteById(long id) {
        return weiboDao.deleteById(id);
    }

    @Autowired
    public void setWeiboDao(WeiboDao weiboDao) {
        this.weiboDao = weiboDao;
    }

}